package com.amor.workpcs.service.impl;

import com.amor.workpcs.entity.Personal;
import com.amor.workpcs.dao.PersonalDao;
import com.amor.workpcs.service.PersonalService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Personal)表服务实现类
 *
 * @author makejava
 * @since 2021-09-14 10:59:59
 */
@Service("personalService")
public class PersonalServiceImpl implements PersonalService {
    @Resource
    private PersonalDao personalDao;

    /**
     * 通过ID查询单条数据
     *
     * @param personalId 主键
     * @return 实例对象
     */
    @Override
    public Personal queryById(Integer personalId) {
        return this.personalDao.queryById(personalId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Personal> queryAllByLimit(int offset, int limit) {
        return this.personalDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param personal 实例对象
     * @return 实例对象
     */
    @Override
    public Personal insert(Personal personal) {
        this.personalDao.insert(personal);
        return personal;
    }

    /**
     * 修改数据
     *
     * @param personal 实例对象
     * @return 实例对象
     */
    @Override
    public Personal update(Personal personal) {
        this.personalDao.update(personal);
        return this.queryById(personal.getPersonalId());
    }

    /**
     * 通过主键删除数据
     *
     * @param personalId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer personalId) {
        return this.personalDao.deleteById(personalId) > 0;
    }
}